<!doctype html>
<html lang="en">
<head>
    <title>Tree - Object Model</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="description" content="Object model" />
    <meta name="keywords" content="" />
    <meta name="author" content="ComponentOne" />
    
    <link href="../../themes/rocket/jquery-wijmo.css" rel="stylesheet" type="text/css" />
    
    <link href="../../themes/wijmo/jquery.wijmo-open.2.1.0.min.css" rel="stylesheet" type="text/css" />
    <link href="../../themes/wijmo/jquery.wijmo.wijtree.css" rel="stylesheet" type="text/css" />
    <script src="../../external/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="../../external/jquery-ui-1.9.1.custom.min.js" type="text/javascript"></script>
    <script src="../../external/jquery.wijmo-open.all.2.3.2.min.js" type="text/javascript"></script>
    <script src="../../Wijmo/jquery.wijmo.wijtree.js" type="text/javascript"></script>
    <script id="scriptInit" type="text/javascript">
        $(document).ready(function () {
            var tv = $("#tree").wijtree();

            function getNode() {
                return $("#tree").wijtree("findNodeByText", "Folder 1"); ;
            }

            $('#addNode').click(function () {
                var node = getNode();
                if (node != null)
                    node.element.wijtreenode("add", 'New node', parseInt($("#addIndex").val()));
            });

            $('#removeNode').click(function () {
                var node = getNode();
                if (node != null)
                    node.element.wijtreenode("remove", parseInt($("#removeIndex").val()));
            });
        });       
    </script>
</head>
<body class="demo-single">
    <div class="container">
        <div class="header">
            <h2>
                Object Model</h2>
        </div>
        <div class="main demo">
            <!-- Begin demo markup -->
            <div>
                <ul id="tree">
                    <li><a><span>Folder 1</span></a>
                        <ul>
                            <li><a><span>Folder 1.1</span></a></li>
                            <li><a><span>Folder 1.2</span></a></li>
                            <li><a><span>Folder 1.3</span></a></li>
                            <li><a><span>Folder 1.4</span></a></li>
                            <li><a><span>Folder 1.5</span></a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <!-- End demo markup -->
            <div class="demo-options">
                <!-- Begin options markup -->
                <div>
                    <input id="addNode" type="button" value="Add" />
                    at index
                    <input id="addIndex" type="text" value="0" />
                </div>
                <div>
                    <input id="removeNode" type="button" value="Remove" />
                    at index
                    <input id="removeIndex" type="text" value="0" />
                </div>
                <!-- End options markup -->
            </div>
        </div>
        <div class="footer demo-description">
		<p>
		This sample shows how to dynamically add and remove nodes from the wijtree widget.  
		</p>
        </div>
    </div>
</body>
</html>
